package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    @PostMapping(value = "/location",name = "上报地理位置")
    public ResponseEntity saveLocation(@RequestBody Map param){
        Double longitude = (Double) param.get("longitude"); //经度
        Double latitude = (Double) param.get("latitude");  //纬度
        String addrStr = (String) param.get("addrStr"); //位置描述

        System.out.println("上传了地址位置"+ param);
        return baiduService.saveLocation(longitude,latitude,addrStr);
    }

}
